import Vue from 'vue'

import Cookies from 'js-cookie'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import Element from 'element-ui'
import './assets/styles/element-variables.scss'

import '@/assets/styles/index.scss' // global css
import '@/assets/styles/wanyun.scss' // wanyun css
import 'element-ui/lib/theme-chalk/index.css'
import '@/styles/index.scss' // global css

import App from './App'
import router from './router'
import store from './store'
import modal from './plugins/modal'
 // 模态框对象
 Vue.prototype.$modal = modal
import './icons' // icon
import './permission' // permission control
import { resetForm, } from "@/utils/wanyun";
import echarts from 'echarts'
import 'echarts/map/js/china.js'
import gallery from 'img-vuer'
// 字典数据组件
import DictData from '@/components/DictData'
DictData.install()
// 字典标签组件
import DictTag from '@/components/DictTag'
Vue.component('DictTag', DictTag)
// 滚动加载更多
Vue.directive('loadMore', {
  bind(el, binding) {
    // 获取element，定义scroll
    let select_dom = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap');
    select_dom.addEventListener('scroll', function () {
      let height = this.scrollHeight - this.scrollTop <= this.clientHeight;
      if (height) {
        binding.value()
      }
    })
  }
});
// 分页组件
import Pagination from "@/components/Pagination";
Vue.component('Pagination', Pagination)
Vue.use(gallery, {
  swipeThredhold: 150,
  isIndexShow: true,
  useCloseButton: true,
  preload: true
})
import * as filters from './filters' // global filters

import permission from '@/directive/permission/index.js' // 权限判断指令
import directive from './directive'
Vue.use(directive)
Vue.use(Element, {
  size: Cookies.get('size') || 'medium' // set element-ui default size
})

import ElImageViewer from "element-ui/packages/image/src/image-viewer";
Vue.component('ElImageViewer', ElImageViewer)

Vue.directive('permission', permission)
Vue.prototype.$echarts = echarts
Vue.prototype.resetForm = resetForm
// register global utility filters.
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})

// window.audioCtx = new (window.AudioContext || window.webkitAudioContext)()
